import * as types from '../mutation-types'
import * as globals from '../../global'

// initial state
const state = {
  mapType: localStorage.mapType || globals.MAP_TYPE_DARK,
  mapbodyfullstatus:false
}

/**
 * 这里的getter永远都会将state传入。
 * getters
 */
const getters = {
  mapType: state => state.mapType,
  mapbodyfullstatus: state => state.mapbodyfullstatus,
}

/**
 * actions
 * 这个包含的是 commit 和 state 或者只包含commit
 * @type {{getHotSpotList: (({ commit, state }:{commit: *, state: *}))}}
 */
const actions = {
  toggleMapType ({ commit, state },mapType) {
    commit(types.TOGGLE_MAP_TYPE,{mapType});
  },
  togglefullstatus( { commit, state }) {
    commit(types.MAP_BODY_FULL_STATUS);
  },

}

/**
 * 多个mutation可以接收同一个action
 * mutations
 * 执行语句
 * @type {{}}
 * 特别注意参数 {}
 */
const mutations = {
  [types.TOGGLE_MAP_TYPE](state,{mapType}){
    localStorage.mapType = mapType;
    state.mapType = mapType;
  },
  [types.MAP_BODY_FULL_STATUS](state){
    state.mapbodyfullstatus = !state.mapbodyfullstatus;
  },
}

export default {
  state,
  getters,
  actions,
  mutations
}
